{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Load and PV production forecast\n",
    "\n",
    "draft December 23th, 2017"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "366×48 Array{Float64,2}:\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0    …  0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.012  0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.012  0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0    …  0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.012  0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0    …  0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.012  0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " ⋮                          ⋮           ⋱                     ⋮              \n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.012  …  0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.012     0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0    …  0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0       0.0    0.0    0.0  0.0  0.0    0.0\n",
       " 0.0  0.0  0.0    0.0  0.0  0.0  0.0    …  0.0    0.0    0.0  0.0  0.0    0.0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data, header = readcsv(\"customer/12/daily_pivot_prod_2011-2012.csv\", header=true)\n",
    "date = data[:,1]\n",
    "data = data[:,2:end]\n",
    "data = map(Float64, data)\n",
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Build the optimization problem associated to the regression\n",
    "\n",
    "to be done"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "using JuMP"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$$ \\begin{alignat*}{1}\\min\\quad & x^2\\\\\n",
       "\\text{Subject to} \\quad & 0 \\leq x \\leq 1\\\\\n",
       "\\end{alignat*}\n",
       " $$"
      ],
      "text/plain": [
       "Minimization problem with:\n",
       " * 0 linear constraints\n",
       " * 1 variable\n",
       "Solver is default solver"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m = Model()\n",
    "@variable(m, 0 <= x <= 1 )\n",
    "\n",
    "@objective(m, Min, x^2)\n",
    "\n",
    "m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "ename": "LoadError",
     "evalue": "\u001b[91mArgumentError: Module Ipopt not found in current path.\nRun `Pkg.add(\"Ipopt\")` to install the Ipopt package.\u001b[39m",
     "output_type": "error",
     "traceback": [
      "\u001b[91mArgumentError: Module Ipopt not found in current path.\nRun `Pkg.add(\"Ipopt\")` to install the Ipopt package.\u001b[39m",
      "",
      "Stacktrace:",
      " [1] \u001b[1m_require\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:428\u001b[22m\u001b[22m",
      " [2] \u001b[1mrequire\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Symbol\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./loading.jl:398\u001b[22m\u001b[22m"
     ]
    }
   ],
   "source": [
    "using Ipopt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "ename": "LoadError",
     "evalue": "\u001b[91mNo solver was provided. JuMP has classified this model as QP. Julia packages which provide solvers for this class of problems include Gurobi, CPLEX, Mosek, Ipopt, and Xpress. The solver must be specified by using either the \"solver=\" keyword argument to \"Model()\" or the \"setsolver()\" method.\u001b[39m",
     "output_type": "error",
     "traceback": [
      "\u001b[91mNo solver was provided. JuMP has classified this model as QP. Julia packages which provide solvers for this class of problems include Gurobi, CPLEX, Mosek, Ipopt, and Xpress. The solver must be specified by using either the \"solver=\" keyword argument to \"Model()\" or the \"setsolver()\" method.\u001b[39m",
      "",
      "Stacktrace:",
      " [1] \u001b[1mno_solver_error\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::JuMP.ProblemTraits\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/home/pierre/.julia/v0.6/JuMP/src/solvers.jl:84\u001b[22m\u001b[22m",
      " [2] \u001b[1m#build#119\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Bool, ::Bool, ::JuMP.ProblemTraits, ::Function, ::JuMP.Model\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/home/pierre/.julia/v0.6/JuMP/src/solvers.jl:298\u001b[22m\u001b[22m",
      " [3] \u001b[1m(::JuMP.#kw##build)\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Array{Any,1}, ::JuMP.#build, ::JuMP.Model\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m./<missing>:0\u001b[22m\u001b[22m",
      " [4] \u001b[1m#solve#116\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::Bool, ::Bool, ::Bool, ::Array{Any,1}, ::Function, ::JuMP.Model\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/home/pierre/.julia/v0.6/JuMP/src/solvers.jl:168\u001b[22m\u001b[22m",
      " [5] \u001b[1msolve\u001b[22m\u001b[22m\u001b[1m(\u001b[22m\u001b[22m::JuMP.Model\u001b[1m)\u001b[22m\u001b[22m at \u001b[1m/home/pierre/.julia/v0.6/JuMP/src/solvers.jl:150\u001b[22m\u001b[22m"
     ]
    }
   ],
   "source": [
    "status = solve(m)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 0.6.0",
   "language": "julia",
   "name": "julia-0.6"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "0.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
